<?php
class BaseController extends Controller {
	//弹出信息
	protected function alert($msg, $url = NULL){
		header("Content-type: text/html; charset=utf-8"); 
		$alert_msg="alert('$msg');";
		if( empty($url) ) {
			$gourl = 'history.go(-1);';
		}else{
			$gourl = "window.location.href = '{$url}'";
		}
		echo "<script>$alert_msg $gourl</script>";
		exit;
	}
	
	//获取url上的第$key个参数 yishouce.com/linux/func/         1: linux    2:func
	protected function _key($key = 1){
		$array = explode('/',$_SERVER['REQUEST_URI']);
		return isset($array[$key])? $array[$key] : '' ;
	}
	
	protected function to($url){
		header("Location: $url",true,'302');
		exit;
	}
}